﻿#include "soundeffectconfig.h"
#include "ui_soundeffectconfig.h"

SoundEffectConfig::SoundEffectConfig(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SoundEffectConfig)
{
    ui->setupUi(this);

    setWindowTitle(QStringLiteral("音效设置"));


    QDir dir(QDir::currentPath() + "/sounds");
    QFileInfoList infoList = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);

    QListIterator<QFileInfo> Iterator(infoList);

    QStringList strDirNameList;

    QFileInfo info;


    while(Iterator.hasNext()) {

        info = Iterator.next();

        if(info.isDir()) strDirNameList << QDir(info.absoluteFilePath()).dirName();

    }

    ui->comboBox->clear();
    for(auto it = strDirNameList.begin(); it != strDirNameList.end(); ++it)
        ui->comboBox->addItem(*it);

    connect(ui->btn_select, SIGNAL(clicked(bool)), this, SLOT(btn_select_slot()));

}

void SoundEffectConfig::btn_select_slot() {

    QString txt = ui->comboBox->currentText();

    if(!txt.length()) return;



    Global::soundSelect = QDir::currentPath() + "/sounds/" + txt;

    //QMessageBox::information(this, QStringLiteral("消息"), QStringLiteral("音效设置成功！"), QStringLiteral("确定"));
    Global::playSoundEffect(QString("/select.wav"));





}

SoundEffectConfig::~SoundEffectConfig()
{
    delete ui;
}
